home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Processes / ProcDoggie2.1b2 / Read Me About ProcDoggie < prev    next >
Encoding:
Text File  |  1997-11-03  |  12.2 KB  |  188 lines  |  [TEXT/ttxt]

  1. ProcDoggie
  2.  
  3. 2.1b2
  4.  
  5. ProcDoggie is a full blown application that demonstrates a variety of Process Manager-related techniques, including:
  6.  
  7. 1. Getting a list of running processes
  8. 2. Getting information about a running process
  9. 3. Launching a processes, with and without opening documents
  10.  
  11. Introduction
  12.  
  13. Description
  14.  
  15. System Software 7.0 includes the Process Manager which allows programs to launch applications and desk accessories, and to get information about other applications and desk accessores that have been launched (both generically known as “processes”).
  16.  
  17. ProcDoggie is a sample application that demonstrates typical uses of the Process Manager.  When ProcDoggie is launched, a window appears which displays a list of all processes that are active on the machine that ProcDoggie is running on.  I call this the “Process List window.”  The user can click on any of the processes in the Process List window to select that process, and can shift-click or command-click to select more than one process.
  18.  
  19. When one or more processes are selected, the user can either view information about those processes, bring those processes to the front, or terminate those processes.  Of course, only one process can be at the front at any time, so each of the selected processes are brought to the front in turn.
  20.  
  21. When the user chooses to view information about the selected processes, a window which I call the “Process Info window” is opened for each of the selected processes.  This window displays information about the type and creator of the process, whether the process is an application or desk accessory, how large its partition is, how much memory it’s using, and the status of the flags in its SIZE resource.
  22.  
  23. The File menu contains commands that the user can use to launch applications and desk accessories.  The user can launch an application or desk accessory so that it becomes the front process, or the user can launch an application so that it becomes a background process, or the user can launch an application or desk accessory and then terminate ProcDoggie.
  24.  
  25. Additionally, the user can choose whether a simple launch is performed or whether the launch should specify documents to be opened or printed by the launched application.
  26.  
  27. Coverage
  28.  
  29. This sample code additionally shows:
  30.  
  31. • simple use of AEInteractWithUser
  32. • MacApp-like menu enabling and disabling
  33. • use of the International Utilities to display formatted numbers
  34. • writing a simple single-line replacement for TextBox
  35. • how to read a DITL resource
  36. • use of courteous colors in a palette
  37. • simple use of MakeRGBPat to display proper colors regardless of the depth of a screen
  38. • simple cases of taking advantage of Color QuickDraw while still running on classic QuickDraw machines
  39. • sending 'oapp' and 'quit' AppleEvents to other applications running on the same machine
  40. • accepting 'quit' AppleEvents
  41. • simple use of the List Manager
  42. • writing a custom LDEF
  43. • using a grow-zone proc to handle low-memory situations
  44.  
  45. Caveats
  46.  
  47. Text drawing should be done using TruncString to ensure that the text fits in the designated cell and, if it doesn’t, to truncate it in an international friendly fashion.
  48.  
  49. ProcDoggie does a “roll your own dialog manager”.  The code for this is described in “UDialogUtils.p”.  Although this is a noble goal, the implementation is flawed.   See the comment in ”UDialogUtils.p” (especially the implementation comment for “InstallDialogItems”) for the reason why.
  50.  
  51. There’s still a lot of code that I’d like to tidy up and bring into my own style in this sample, but I’ve decided to not do that under the maxim “If it works, don’t mess with it.” — Quinn, 17 Mar 1997
  52.  
  53. Details
  54.  
  55. Building ProcDoggie
  56.  
  57. ProcDoggie was built using Metrowerks CodeWarrior Pro 1’s Pascal compiler.  To build ProcDoggie, simply open the “ProcDoggie.µ” project and choose Make from the Project menu.
  58.  
  59. Packing List
  60.  
  61. The following files are included in the distribution:
  62.  
  63. • Read Me About ProcDoggie — This document.
  64.  
  65. • ProcDoggie.µ — The project to build the 68K, PPC and FAT versions.
  66. • ProcDoggie — The compiled FAT application.
  67.  
  68. • ProcDoggie.p — The main line of the application.
  69. • UEvents.p — The event handling code for the application.
  70. • UMenuHandler.p — The menu handling code for the application
  71. • UProcessGuts.p — The core code to handle the process list window and the process info windows.
  72. • UProcessLDEF.p — The LDEF code for the process list window.
  73. • UProcessUtils.p — Some Process Manager utilities.
  74. • UGlobals.p — Application globals and utility routines.
  75. • UDialogUtils.p — A “roll your own dialog manager” module.  See the Caveats sections of this document for why this is not recommended.
  76. • UEmergMem.p — A memory library for wrapping the system Memory Manager to avoid very low memory conditions.
  77.  
  78. • ProcDoggie.rsrc — The bulk of the application’s resources.
  79. • ProcDoggie.r — A special 'DITL' resource.  This exists because the ResEdit 'DITL' editor won’t edit this special 'DITL' because of it’s weird format.  See the Caveats sections of this document for an explanation.
  80.  
  81. • StubLDEF — A tiny LDEF that simply calls through the ListHandle’s refCon field. Using this allows the real LDEF code to reside in the application, which is useful for the PPC port and aids in debugging.
  82.  
  83. End Matter
  84.  
  85. Credits
  86.  
  87. If you find any problems with this sample, mail <DevSupport@apple.com> with “Attn: Quinn” as the first line of your mail and I’ll try to fix them up.
  88.  
  89. The sample was originally written by Forrest Tanaka.
  90.  
  91. Thanks to Jeff Hokit for inspiring the name.
  92.  
  93. Significant maintenance (including the PowerPC conversion) was done by Quinn “The Eskimo!”.
  94.  
  95. Share and Enjoy
  96.  
  97. Quinn “The Eskimo!”
  98. Apple Developer Technical Support
  99. Networking, Communications, Hardware
  100. [And Pascal guru, which is why I’m maintaining this sample (–: ]
  101.  
  102. Version History
  103.  
  104. Version 1.0a1
  105. Date unknown by Forrest Tanaka
  106.  
  107. This version had all features except the ability to terminate processes implemented, but very little of the user interface was implemented.  Never released to AppleLink
  108.  
  109. Version 1.0a2
  110. Date unknown by Forrest Tanaka
  111.  
  112. The same features were there, but the user interface was much more complete. Never released to AppleLink.
  113.  
  114. Version 1.0a3
  115. November 3, 1990 by Forrest Tanaka
  116.  
  117. This version has features as described above with the exception of being able to terminate selected processes.  Readied for release on AppleLink on November 3.
  118.  
  119. Version 1.0a4
  120. No date
  121.  
  122. This version never existed.  I renumbered everything as 1.0a5 by mistake.
  123.  
  124. Version 1.0a5
  125. December 18, 1990 by Forrest Tanaka
  126.  
  127. • The ability to terminate selected processes has been added.
  128. • Error-checking and recovery has been massively improved.  In theory, ProcDoggie should never bomb with any kind of error.
  129. • High-level events are now accepted, though only 'quit' AppleEvents are handled because ProcDoggie has no documents.
  130. • Previously, ProcDoggie didn’t send 'oapp' events to applications which were high-level event aware, nor did it properly send 'odoc' events to those applications.  These problems have been fixed.
  131. • The Utilities sample code unit is no longer used.  All the Utilities functionality I was using has been absorbed into ProcDoggie.
  132. • If an alert is about to be presented while ProcDoggie is in the back- ground, the Notification Manager is used to alert the user that ProcDoggie has something to say.
  133. • Readied for release on AppleLink on December 18.
  134.  
  135. Version 1.0a6
  136. February 6, 1991 by Forrest Tanaka
  137.  
  138. • DrawMenuBar bombs after I send a quit event to MacPaint (and a few other applications) and then delete the selected row in the process list.  So I changed the DrawMenuBar call to InvalMenuBar and it seems to work around the problem.  I don’t know why DrawMenuBar has a problem in this specific case involving the Menu, AppleEvent, and List managers.
  139. • In InstallDialogItems, I was calling GetIndString with an index of 0 if there isn’t a specified font name.  GetIndString bombs under 7.0b4 if you do that so now I check for this case.
  140. • My LDEF was drawing a cell even if the specified length of the cell’s data was 0.  That caused garbage to appear in new cells until I set a real value in the cell.  Now, I don’t draw the cell if the length of the cell’s data is 0.
  141. • I think my LDEF now draws the process names from right aligned on a bidirectional script system.  Since I don’t have a bidirectional 7.0 script system, I can’t test this yet.
  142. • Because of a bug in file filtering in 7.0b1, I used SFGetFile instead of StandardGetFile.  With 7.0b1 dead and buried, I’m now using StandardGetFile.
  143. • Dammit Jim!  I’m a C programmer, not a Pascal programmer.  I turned off range checking in all the source code files.
  144. • I eliminated the UWindowHandler unit and moved the routines that were in it to ProcDoggie.p and the UGlobals unit.
  145.  
  146. Version 2.1b1
  147. 18 March 1997, by Quinn “The Eskimo!”
  148.  
  149. • The read me described version 1.0a6 as the latest version, but the application had version 2.0 in its 'vers' resource.  I’ve upgrade to 2.1 to avoid any confusion.
  150. • Converted to Metrowerks Pascal.
  151. • Removed ‘include file madness’ that was an artifact of the MPW Pascal environment.  Halved the number of source files.   Yippee!
  152. • Got rid of “ProcDoggie.r”, which only included a single DITL resource that I rolled into “ProcDoggie.rsrc”.
  153. • Made the AppleEvent handlers take VAR AppleEvents in preparation for PPC conversion.
  154. • Turned on all compiler warnings and eliminated any problems thereby caused.
  155. • Rationalise list of units each unit USES.
  156. • Install standard DTS disclaimer in all source files..
  157. • TerminateProcess was not setting the error result for the noErr case.
  158. • Only unhilite a menu if we’re not quitting.
  159. • Rolled “ProcDoggie.r” back into the source and put a comment in it that explains why it’s needed.
  160. • Changed the number format resource from 'NUMF' ID=0 to 'FMAT' ID=128.  The type change allows me to edit it using Michael Hecht’s way cool ResEdit editor for 'FMAT' resources.  The ID change is to bring the resource into the application resource ID range.
  161. • Turned range checking back on; we’ll see what errors it spits out.
  162. • Renamed “%A5Init” (a serious MPW-ism) segment to “Startup”.
  163. • Checked for and eliminated other weird compiler directives.
  164. • Conditionalised UnloadSeg call for classic runtime.
  165. • Added a Close menu command because testing it without one was driving me nuts!
  166. • Change ProcessListInfoRec to hold a Str255 for the process name, a Str31 is definitely not enough!
  167. • Reworked NotifyAlert to use AEInteractWithUser.
  168. • Changed all BlockMove's to BlockMoveData's.
  169. • We now check for System 7 at startup and bail out if we don’t have it.
  170. • Confirmed why can’t DoBringProcessToFront yank ProcDoggie to front. See the comment for the implementation of DoBringProcessToFront in “UProcessGuts.p”.
  171. • Wrote a single number to string routine (MyNumberString) which is now called by both “SetUpProcessInfoItems” and “IdleProcessInfoWindow”. The old code had two identical copies of the same routine.
  172. • Ran it under Appearance (Mac OS 8.0a3) to check that the Palette Manager code looks OK there.
  173. • Checked the standard file filter routine for “opening already open file” problem -- did some research and the current code will work fine is all cirumstances because it opens the file read-only.
  174. • Process info window now displays new process flags, namely modeUseTextEditServices and modeDisplayManagerAware.
  175. • Changed idle function in NotifyAlert to handle update events. Doing this involved taking the event handling code out of “ProcDoggie.p” into “UEvents.p” so that “UGlobals.p” can import the DoEvent routine.
  176. • The possibility of user interaction being denied now means that NotifyAlert (and the other alert functions that call it) must return an error.
  177. • PPC port — add lots of UPPs.
  178. • PPC port — rationalised handling of floating point numbers when calling ExtendedToString
  179. • PPC port — converted LDEF to VAR cellRect: Rect to avoid crashing
  180. • Fixed an update bug introduced when implementing MyNumberString.
  181.  
  182.  
  183. Version 2.1b2
  184. 28 Oct 1997, by Quinn “The Eskimo!”
  185.  
  186. • SetGrowZone(gzUPP) is much better than SetGrowZone(@gzUPP).  It seems that the grow zone routine had never been tested, because this bug would have caused it to crash every time.  I found this by testing on Mac OS 8.0 + Japanese Language Kit 1.2 + Language Kit Updater, which seems to call the grow zone routine on a regular basis, even if there's plenty of RAM in the heap.
  187. • Updated the projects to CodeWarrior Pro 1.
  188.